<!-- z-paging聊天item -->

<template>
	<view class="chat-item">
		<view class="card" v-if="item?.type === 3">
			<view class="top">
				<view class="title-icon-box">
					<image class="icon" src="../../static/orders/orders_msg.png" mode="aspectFit"></image>
					<view class="title">系统消息</view>
				</view>
				<view class="time">{{item.createTime}}</view>
			</view>
			<view class="content">
				{{item.content}}
			</view>
		</view>
		<view class="" v-else>
			<view :class="{'chat-time':true,'chat-location-me':item?.creator === globalStore?.userInfo.id}"
				v-if="item.createTime&&item.createTime.length">
				{{item.createTime}}
			</view>
			<view :class="{'chat-container':true,'chat-location-me':item?.creator === globalStore?.userInfo.id}">
				<view class="chat-icon-container">
					<image class="chat-icon"
						:src="item.type * 1 === 4 ? '../../static/orders/kefu_icon.png' : replaceUrl(item?.createPhoto)"
						mode="aspectFill" />
				</view>
				<view class="chat-content-container">
					<text :class="{'chat-user-name':true,'chat-location-me':item?.creator === globalStore?.userInfo.id}"
						:style="{background:item.type===4?'#6F69E9':item?.creator === globalStore?.userInfo.id?'#FFE526':'#26FFF7'}">
						{{ item.type * 1 === 1 ? '发单' : item.type * 1 === 2 ? '接单' : item.type * 1 === 3 ? '系统' : '客服'}}
					</text>

					<view class="chat-text-container-super"
						:style="[{justifyContent:item?.creator === globalStore?.userInfo.id?'flex-end':'flex-start'}]">
						<view
							:class="{'chat-text-container':true,'chat-text-container-me':item?.creator === globalStore?.userInfo.id}">
							<text v-if="[1,3,4].includes(item.messageType)"
								:class="{'chat-text':true,'chat-text-me':item?.creator === globalStore?.userInfo.id}">{{item.content}}</text>
							<uv-album v-if="[2,3].includes(item.messageType)"
								:urls="[replaceUrl(item?.url)]"></uv-album>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import useStore from '@/stores'
	const {
		globalStore
	} = useStore()
	import {
		replaceUrl
	} from '@/utils';
	const props = defineProps({
		item: {
			type: Object
		}
	});
</script>

<style scoped lang="scss">
	.card {
		padding: 32rpx;
		background: #fff;
		border-radius: 16rpx;
		margin: 40rpx 20rpx;
		border: 2rpx solid rgba(151, 151, 151, 0.1);

		.top {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.title-icon-box {
				display: flex;
				align-items: center;

				.icon {
					width: 40rpx;
					height: 40rpx;
				}

				.title {
					font-size: 32rpx;
					font-weight: 600;
					color: #222222;
					margin-left: 8rpx;
				}
			}

			.time {
				color: #999999;
				margin-top: 4rpx;
				font-size: 28rpx;
			}
		}

		.content {
			margin-top: 24rpx;
			font-size: 28rpx;
			color: #666666;
			line-height: 48rpx;
		}
	}

	.img-box {
		width: 100vw;
		height: 100vh;
		position: relative;
		background-color: #000000;

		.closeIcon {
			position: absolute;
			right: 30rpx;
			top: 30rpx;
			z-index: 100;
		}

		.img {
			width: 100%;
			height: 100%;
		}
	}



	.chat-item {
		display: flex;
		flex-direction: column;
		padding: 20rpx;
	}

	.chat-time {
		padding: 4rpx 0rpx;
		font-size: 22rpx;
		color: #aaaaaa;
	}

	.chat-container {
		display: flex;
		flex-direction: row;
	}

	.chat-location-me {
		flex-direction: row-reverse;
		text-align: right;
	}

	.chat-icon-container {
	}

	.chat-icon {
		width: 72rpx;
		height: 72rpx;
		border-radius: 50%;
		background-color: #eeeeee;
	}

	.chat-content-container {
		margin: 0rpx 15rpx;
	}

	.tag {
		width: 64rpx;
		font-size: 20rpx;
		color: #222222;
		font-weight: 700;
		text-align: center;
		line-height: 32rpx;
		height: 32rpx;
		border-radius: 8rpx;
	}

	.chat-user-name {
		font-size: 24rpx;
		color: #222222;
		font-family: 600;
		border-radius: 10rpx;
		padding: 5rpx 10rpx;
	}

	.chat-text-container {
		text-align: left;
		background-color: #fff;
		line-height: 42rpx;
		border-radius: 8rpx;
		padding: 10rpx 15rpx;
		margin-top: 10rpx;
		/* #ifndef APP-NVUE */
		max-width: 500rpx;
		/* #endif */
	}

	.chat-text-container-me {
		background-color: #6E68E9;
	}

	.chat-text-container-super {
		display: flex;
		flex-direction: row;
		
	}

	.chat-text {
		font-size: 28rpx;
		/* #ifndef APP-NVUE */
		word-break: break-all;
		/* #endif */
		/* #ifdef APP-NVUE */
		max-width: 500rpx;
		/* #endif */
	}

	.chat-text-me {
		color: white;
	}
</style>